Skip to content

UI: three more functions at 100%: the lobby's start button, the save list's header and the mission rows - #423

Merged
TheRedDaemon merged 8 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-B-round17-100
Nov 24, 2026
Merged

TheRedDaemon merged 8 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-B-round17-100

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Three more UI functions at 100%. From the review, INT_00b96100 and INT_00b95b2c (DAT_00b96100 and DAT_00b95b2c until now) and the file list's sort order became ints, with a FileListSortOrder enum for the sort order's values. Main has these header changes since its Ghidra sync 8e1e77f, so the branch no longer changes a header. The lobby's start button comes from our draft #327, and the other two are rewritten from the binary with gynt's drafts for the names.

Function Address Before reccmp raw Normalised
LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick 0x00442640 our draft #327 (cb601a0, 1918de9): 90.7% in #327's status line, 90.3% built on main's code; gynt's 80.71% (35aef55; newest on the file dd1a7c4) 100.0 100.0
SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader 0x00492DE0 gynt's 49.40% (21d4dcf; newest on the file 8725ec5, 49.4%) 100.0 100.0
HistoricMissionSelect::MenuItemRenderFunction_HistoricMissionSelect_MissionRows 0x004269E0 gynt's 44.53% (626fd68) 100.0 100.0

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.
  • Full build: an all-on build of this branch merged with main 48f7e94, with main's own /GL list, and with 0x004314E0 (the MapEditorLandscaping_GeneralButtons handler) left out and its resolver off, as in main's baseline, together with requestGoods (0x004D1F00) and MenuItemActionHandler_Allies_Main (0x004B12D0), which do not compile on 48f7e94 until Reimplement 29 Synchrony and Game functions at 100% #403 renames their two PlayerData fields: 0 failed of 2,469 compile steps, 99.59 over 2,485 functions, against 99.59 over 2,482 for main alone (unrounded 99.5920 and 99.5915 raw, 2,368 and 2,365 functions at 100.0). All three functions read 100.0 raw and normalised, with no diff entry. With the header changes, all eight of main's users of DAT_00b96100, DAT_00b95b2c, fileListSortOrder and savedListSortOrder1 to 3 read 100.0 as before, and every other function reads exactly what it reads in the same build of main.
  • The build's commit: it ran on a local merge of this branch with main 48f7e94, at a commit that was not pushed. The head's tree differs from it by one comment in MissionRows and the arrows' four case labels in the table header, now FileListSortOrder names with the same values. Narrow builds of the two files in their final form read 100.0 raw and normalised, with no diff line.
  • Checks: openshc-pr-fix finds nothing to change, and openshc-pr-check gave 0 ERROR and 27 CHECK; on the head it gives 30, all explained below.
  • Not run in game.
  • Update, merge with main 8e1e77f: main's Ghidra sync for this PR named the two globals INT_00b95b2c and INT_00b96100. 37802ec merges main in, and ac932fc moves the mission rows to the new names. It also moves main's MenuItemActionHandler_HistoricMissionSelect_General and MenuView_HistoricMissionSelect_Prepare, which still include the removed DAT_ headers and so don't compile on 8e1e77f. A narrow real build of ac932fc reads MissionRows, the table header, General and Prepare at 100.0 raw and normalised, and the lobby's start button at 99.3 (83.3 normalised), as after the last main merge (see below). The fixer changes nothing, and the checker gives 0 ERROR and 30 CHECK.

What got them to 100%

  • Lobby start button (the Reimplement 2 UI::MenuItems functions (draft, below 100%) #327 draft reads 90.3% built on main's code, 90.7% in Reimplement 2 UI::MenuItems functions (draft, below 100%) #327's status line; now 100%):
    • Case 4 sets the draw buffer back once, after the if / else that launches the game, because the original pops three registers before that store in the skirmish arm.
    • The two keep-position loops read keepPositions[position].x where they use it, with no local.
    • Case 105's map index goes through a local declared before the switch. Of the 32 combinations of how the three sums are written, only this one and its twin with case 105's operands swapped match. A local declared in case 105 swaps case 4's two loads.
    • With main 45767c4 merged in, the same source reads 99.3% (83.3% normalised): case 105's two loads tie in the register allocator, and main's header syncs since d502a12 moved the tie the other way, the last step with d616fa9, the same as for LaunchSinglePlayerGameUnk on main. It reads 100.0% on this branch and with main up to d502a12; the source is unchanged.
  • SaveLoadMap table header:
    • The order is stored in each arm, and previewedListIndex = -1 is written once after the if / else. MSVC copies that store into both arms after the last pop, as the original has it.
    • The swap reads the moved element into a local inside the if.
    • fileListEntryCount is read in the loop condition, because the original reloads it after each swap's stores.
  • MissionRows:
    • The number and the name are written in each of the three arms, so MSVC hoists their common pushes and shares the tail.
    • The number's position is written out in each arm.
    • In the selected arm, the name's position and index go into locals before the nested call, in the order the original loads them.

Behaviour compared with the drafts

  • Lobby start button: load game (1) and start game (4) return as soon as an occupied slot isn't ready, where gynt's draft only left the loop and carried on. For the host, dropping a keep position (-201) ends with INT_00b95960 = -1 on every path, and stops when no position is under the mouse.
  • MissionRows: a mission not reached yet is drawn as a greyed cell and the function returns (0x00426A53). The draft went on and drew the number and the name over it.
  • SaveLoadMap table header: the behaviour is the draft's. Its DAT_ArrayOfMapIndices[i - 1] was right on gynt's branch, where the array is declared at offset 0x884. Main's sync 12854bc moved the declared start to 0x880, so the index here is [i].

Headers changed (from the review, now on main)

One header commit, e7d2efc, with data.asm's two symbols in the commit after it, 0ccba1a, so a build with their struct resolvers off links. Main has both since 8e1e77f, with the two globals named INT_00b96100 and INT_00b95b2c.

  • INT_00b96100 and INT_00b95b2c (DAT_… until now) are ints. MenuView_HistoricMissionSelect_Prepare (0x00426830) works out the shown campaign from missionNumber1to20 and stores its index, 0 to 3, in INT_00b95b2c and its first mission, index * 5 + 1, in INT_00b96100 (0x00426879 / 0x0042687E and the two other arms). MissionRows compares INT_00b96100 - row - 1 with that campaign's progress signed (jle at 0x00426A22), so the (int) cast is gone.
  • FileListSortOrder is a new enum for the file list's sort order: FLSO_BY_NAME 0 (the list as discoverMapFiles sorts it, A to Z), FLSO_BY_NAME_REVERSED 1, FLSO_BY_TIME_NEWEST_FIRST 2 and FLSO_BY_TIME_OLDEST_FIRST 3. The table header's four sorts end in these values (0x00492FA2, 0x00492F69, 0x00492F25, 0x00492EB5), and it now writes them by name, also as the labels of the arrows' switch, which is on -1 - button, the order the sort ends in.
  • MenuTextInputState::fileListSortOrder and its saved copies savedListSortOrder1 to 3 are now ints, where they were undefined4. They are not typed with the enum: with FileListSortOrder.hpp included by MenuTextInputState.hpp, which many files include, its declarations swapped two registers in LobbyscreenStartButtonClick and LaunchSinglePlayerGameUnk, which don't use it. So only the table header includes the enum.

What the placeholders hold

These are read from how the code uses them. Ghidra has no better names, so the names are unchanged.

  • DAT_00b960dc: the lobby's fade. It is non-zero while the menu fades in or out, and the handler ignores clicks while it is non-zero.
  • DAT_00b960f4: the map description's scroll offset.
  • INT_00b95b74: probably the description text's height, since the scroll limit is this value minus 114.
  • INT_00b95960: the player position being dragged onto another keep, or -1 when nothing is being dragged.
  • INT_00b95f64: the keep slot that position was picked up from.
  • INT_00b96100: the first mission of the campaign the list shows (1, 6, 11 or 16); a row shows mission INT_00b96100 - row - 1.
  • INT_00b95b2c: that campaign's index, 0 to 3, which indexes the four progress entries in ScenarioProgress.
  • MenuTextInputState::field_0x9c: set to 1 before the lobby opens the load dialog. I don't know what it means.

The checker's 30 CHECKs

Count Where Finding Why it stays
7 Lobby :201, :202, :203, :209, :210, :211, :212 placeholder DAT_00b960f4 explained above
3 Lobby :236, :246, :271 placeholder INT_00b95960 explained above
3 Lobby :237, :262, :263 placeholder INT_00b95f64 explained above
1 Lobby :41 placeholder DAT_00b960dc explained above
1 Lobby :77 placeholder field_0x9c explained above
1 Lobby :208 placeholder INT_00b95b74 explained above
1 Lobby :50 15 numeric case labels these are the buttons' action numbers, and no enum exists for them; most cases carry a comment
1 TableHeader :37 2 numeric case labels the column, 0 name and 1 time, and no enum exists for it; the arrows' switch above it and the orders it stores use the FileListSortOrder names
5 MissionRows :35, :50, :61, :71, :79 placeholder INT_00b96100 explained above
1 MissionRows :36 placeholder INT_00b95b2c explained above
1 MissionRows :53 comment about matching the one line that says why the calls are written in each arm
2 General :28, Prepare :41 placeholder INT_00b96100 main's two files, moved to the new name only; explained above
1 Prepare :40 placeholder INT_00b95b2c the same
1 General :39 style-lint: goto main's own code in that handler, unchanged here
1 (branch) the style-lint bot would post 1 finding the same goto; the bot comments only when a PR opens

Proposed, not changed here

  • ScenarioProgress as an array: MissionRows :36 reads (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[INT_00b95b2c::instance], indexing the four campaign entries from the first one. They could be an int[4] indexed by a campaign enum in the fields' order (Call to Arms, Saladin's Conquest, The King's Crusade, Crusader States), which would make this a plain index. That changes GameCore.hpp, and Constructor_GameCore and incrementMissionProgress on main, so it seems better done with the Ghidra sync. Not measured.
  • loadOrSaveGame(int): the options click handler passes it 9 for Load (0x00496C85) and 10 for Save (0x00496CFA), which are MMT_LOAD_MAP and MMT_SAVE_MAP. Its parameter is probably a MenuModalType, and the lobby's 9 is probably MMT_LOAD_MAP.

One function leaves #327

The lobby's start button moves here from the draft #327. 942d855 on #327 takes it out of that draft.

🤖 Generated with Claude Code

kotijekriv and others added 3 commits November 18, 2026 17:34
LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick, from gynt's draft (c0a2f52 at 40.85% on his
fork's development; c88d7a2 at 40.8% on upstream's reimpl/UI-MenuItems; f53ef94 to d81f02f, 54.93% to 69.03%,
his fork's reimpl/UI-MenuItems; a4fb7c2 of 2026-10-28 on his fork's reimpl/Wilps-2026-10-18; 99cb905 at 80.53%,
35aef55 at 80.71% and dd1a7c4 of 2026-11-02, his newest commit on the file, on his fork's
reimpl/UI-MenuItems-development) and our cb601a0 and 1918de9 in draft sourcehold#327 (90.7%).

90.3% -> 100.0% on main 3458fea:
- case 4 sets the draw buffer back once, after the if / else that launches the game: the original pops three
  registers before that store in the skirmish arm (pop esi / pop ebp / pop ebx / mov / pop edi / ret);
- the two keep-position loops read keepPositions[position].x where they use it, with no local, which gives
  lea ebp, [eax + edi + 572] with x as the base (a local gave [edi + eax + 572]);
- the map index. Case 4 writes its two sums as DAT_MapSelectionScrollOffset + DAT_MapSelectionRelativeSelected, and
  case 105 takes its index through a local that is declared before the switch. That gives both cases the
  original's two loads and add (0x0044284E: edx, eax, add eax, edx; 0x00442AD8: ecx, edx, add edx, ecx). The three
  sums are coupled: of 32 combinations (each case's sum written out, as a block-scope local or as this local, in
  both operand orders) only this one and its twin with case 105's operands swapped match. A block-scope local in
  case 105 swaps case 4's loads, which is why the declaration stands before the switch, with one comment line. The local starts at 0, which nothing
  reads: declared without a value, style rule 24 asks for it in case 105, and the code is the same either way.

quick_diff reads 0.9956: its two lines are a tail jump it prints as a label and the jmp over the first loop's
alignment padding; it cannot see the load order, since it prints both fields as [G].

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader, rewritten from the binary with gynt's draft for the names
(f788afb at 17.2% on upstream's reimpl/UI-MenuItems; 54e57c4 and 21d4dcf at 47.81% and 49.40% on his fork's
reimpl/UI-MenuItems; 8725ec5 at 49.4% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the
file). reccmp 100.0 (normalized 100.0) on
main 3458fea with the data and its own function resolver on; the draft reads 47.8 there.

The array index changed with the header. gynt's draft uses DAT_ArrayOfMapIndices[i - 1] and [i], which was right on his
branch, where the array is declared at offset 0x884. Main's sync 12854bc (2026-11-04) moved the declared start to
0x880, so the original's 0x01126E28 and 0x01126E2C are [i] and [i + 1] here.

- The order store is in each arm and previewedListIndex = -1 is written once after the if / else. MSVC copies that store into both arms, after the last pop, as the original has it; only the order store sits
  between the pops. Written in each arm, it keeps -1 in ebx and pushes
  ebx at the top, and the first sort's two loops lose their alignment padding.
- The swap reads the moved element into a local inside the if. With both elements in locals before the test they
  land in each other's registers.
- fileListEntryCount is read in the loop condition: the original reloads it after each swap's stores.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HistoricMissionSelect::MenuItemRenderFunction_HistoricMissionSelect_MissionRows, rewritten from the binary with gynt's
draft for the names (298b3af at 20.6% on upstream's reimpl/UI-MenuItems; 633d784 at 41.41% on his fork's
reimpl/UI-MenuItems; 626fd68 at 44.53% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the
file). reccmp 100.0 (normalized 100.0) on main 3458fea with the data and its own function resolver on; the draft
reads 45.3 there.

Behaviour: a mission not reached yet is drawn as a greyed cell and the function returns (0x00426A53). The draft went
on and drew the number and the name over it.

- The number and the name are written in each of the three arms, and DAT_ButtonUnknownZero = FALSE once after them:
  MSVC hoists the arms' common pushes and shares the tail, as the original has it.
- The number's position is written out in each arm; with locals for it the two loads come in the other order.
- In the selected arm the name's position and index are read into locals before the nested call, Y, X, then the
  index, which gives the original's registers for that call.
- The locked test compares (int)(DAT_00b96100 - row - 1): the global is an undefined4, and the original's jle is signed.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 3 commits November 23, 2026 23:22
…e ints, and a FileListSortOrder enum

DAT_00b96100 is the first mission of the historic campaign the mission list shows (1, 6, 11 or 16), and
DAT_00b95b2c is that campaign's index (0 to 3). MenuView_HistoricMissionSelect_Prepare (0x00426830) picks the
campaign from missionNumber1to20 and stores the index and index * 5 + 1 (0x00426879 / 0x0042687E and the two other
arms). The mission rows compare DAT_00b96100 - row - 1 with that campaign's progress signed (jle at 0x00426A22),
so DAT_00b96100 is an int, and DAT_00b95b2c, an index from 0 to 3, is one with it. Their data.asm symbols follow in
the next commit.

MenuTextInputState::fileListSortOrder holds one of four orders of the load / save file list, and the three
savedListSortOrder fields hold copies of it; all four are now int. The values get names in a new FileListSortOrder
enum: 0 by name, A to Z, as discoverMapFiles sorts the list, 1 Z to A, 2 by file time newest first, 3 oldest first. The
table header's four sorts end in those values (0x00492FA2, 0x00492F69, 0x00492F25, 0x00492EB5). Only the table
header includes the enum: included by MenuTextInputState.hpp, which many files include, its declarations swap two
registers in LobbyscreenStartButtonClick and LaunchSinglePlayerGameUnk.

Header changes only. The users on main 48f7e94 and on this branch compile to the same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
data.asm names the instances at 0x00B96100 and 0x00B95B2C with the int type (H instead of I), as it does for main's
other int globals, to go with the header commit before it. The Extern symbol's name carries the type, so a build with
their struct resolvers off links only with both commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MissionRows tests DAT_00b96100, now an int, without a cast. The table header writes its sort orders as
FileListSortOrder names, and its first switch's labels too: that switch is on -1 - button, the order the handler
ends in. The listings are the same: narrow builds of this branch's files and of every user of the two globals and
the four fields read 100.0 raw and normalised, with no diff line, before and after, and so do a full build of the
branch merged with main 48f7e94 and narrow builds of these two files in their final form.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 23, 2026
gynt added a commit that referenced this pull request Nov 24, 2026
kotijekriv and others added 2 commits November 24, 2026 18:59
Main's header sync renamed the two globals to INT_00b95b2c and INT_00b96100, so main's two headers are taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's header sync named DAT_00b95b2c and DAT_00b96100 INT_00b95b2c and INT_00b96100. The mission rows, and main's
General handler and Prepare view, include the new headers and use the new names. Main's two files have not compiled
since the sync without this. The code is otherwise the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 24, 2026
@TheRedDaemon
TheRedDaemon added this pull request to the merge queue Nov 24, 2026
Merged via the queue into sourcehold:main with commit 0268112 Nov 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants